package aishua.com.mytestapplist.hencoder;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by aishua on 2018/1/10.
 */

public class HencoderDrawArc extends View {
    private static final String TAG = "HencoderDrawArc-";
    private Paint paint;
    public HencoderDrawArc(Context context) {
        super(context);
    }

    public HencoderDrawArc(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public HencoderDrawArc(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        paint = new Paint();
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.BLUE);
        canvas.drawArc(new RectF(100,100,500,500),0,120,false,paint);
        canvas.drawArc(new RectF(100,100,500,500),120,100,true,paint);
        paint.setColor(Color.GREEN);
        paint.setStyle(Paint.Style.STROKE);
        paint.setAntiAlias(true);
        canvas.drawArc(new RectF(100,100,500,500),220,100,false,paint);
        canvas.drawArc(new RectF(100,100,500,500),320,40,true,paint);
        drawPath(canvas);
    }

    public void drawPath(Canvas canvas){

        paint.setColor(Color.BLACK);
        Path path = new Path();
//        path.addArc(new RectF(100,600,500,1000),0,120);
        paint.setStyle(Paint.Style.FILL);
        path.addCircle(100,600,200, Path.Direction.CCW);
        path.addCircle(150,600,200, Path.Direction.CW);
        canvas.drawPath(path,paint);

    }
}
